--使用方法：直接粘贴到模组环境 修改"abc"为玩家对应tag

local playertag = "abc"

-- 新旧简易血条
TUNING.MODHOOK_JYXT_MM = ArrayUnion(TUNING.MODHOOK_JYXT_MM or {}, {
    "workshop-2373373592",
    "workshop-1651623054",
    "workshop-1207269058"
})
for k, v in pairs(TUNING.MODHOOK_JYXT_MM) do
    local modenv = ModManager:GetMod(v)
    if modenv then
        local postinitfns = modenv.postinitfns.ComponentPostInit.health
        local fn1 = postinitfns and postinitfns[1]
        if fn1 then
            -- 扣血时不显示
            modenv.postinitfns.ComponentPostInit.health[1] = function(a, b)
                if b and b:HasTag(playertag) then
                    return
                end
                fn1(a, b)
            end
        end
        local postinitfns2 = modenv.postinitfns.ComponentPostInit.combat
        local fn2 = postinitfns2 and postinitfns2[1]
        if fn2 then
            -- 挨打/被盯上时不显示
            local function NewCombatDYC(self, owner)
                if owner and owner:HasTag(playertag) then return end 

                local oldSetTarget = self.SetTarget
                local oldGetAttacked = self.GetAttacked
                fn2(self, owner)
                local newSetTarget = self.SetTarget
                local newGetAttacked = self.GetAttacked

                self.SetTarget = function(self, target, ...)
                    if target and target:HasTag(playertag) then
                        return oldSetTarget(self, target, ...)
                    end
                    return newSetTarget(self, target, ...)
                end
                self.GetAttacked = function(self, attacker, ...)
                    if attacker and attacker:HasTag(playertag) then
                        return oldGetAttacked(self, attacker, ...)
                    end
                    return newGetAttacked(self, attacker, ...)
                end
            end
            modenv.postinitfns.ComponentPostInit.combat[1] = NewCombatDYC
        end
    end
end

-- 登仙
AddComponentPostInit("xd_xuetiao", function(xd_xuetiao, inst)
    if inst and inst:HasTag(playertag) then
        function xd_xuetiao:ShowXueTiao(doer)
            self:HideXueTiao()
        end
    end
end)